home *** CD-ROM | disk | FTP | other *** search
- /* fpreset.c function, from p. 214 of turbo c bible */
- #include<math.h>
- #include<stdio.h>
- #include<float.h>
- #include<setjmp.h>
- #include<signal.h>
- void myfphandler(int);
- jmp_buf this_point;
- main()
- {
- double a = 1.0, b = 0.0, c;
-
- if(signal(SIGFPE, myfphandler) == SIG_ERR)
- {
- abort();
- }
- if(setjump(this_point) == 0)
- {
- c = a/b;
- }
- printf("recoverd from floating point error\n");
- }
- /*------------------------------------------------*/
- void myfphandler(int sig)
- {
- printf("in handler: signal = %d\n", sig);
- _fpreset();
- longjump(this_point, -1);
- }